package cn.tedu.baking.controller;

import cn.tedu.baking.mapper.CategoryMapper;
import cn.tedu.baking.pojo.vo.CategoryVO;
import cn.tedu.baking.response.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *  分类处理的控制器类:
 */
@RestController
public class CategoryController {
    //http://localhost:8080/v1/categories/3/sub
    @Autowired
    CategoryMapper categoryMapper;
    @GetMapping("/v1/categories/{type}/sub")
    public JsonResult selectCategoryByType(@PathVariable Integer type){
        List<CategoryVO> categoryVOS = categoryMapper.selectCategoryByType(type);
        return JsonResult.ok(categoryVOS);
    }
}
